class Node:
    def __init__(self, data):
        self.data = data
        self.next = None


class Linqueue:
    def __init__(self):
        p = Node(None)
        self.front = self.rear = p

    # 入队操作
    def push(self, e):
        p = Node(e)
        self.rear.next = p
        self.rear = p

    # 出队操作
    def pop(self):
        if self.empty():
            return False
        p = self.front.next
        self.front.next = p.next
        if p == self.rear:
            self.rear = self.front
        return True

    # 是否为空
    def empty(self):
        return self.rear == self.front

    # 获取对头元素
    def getfront(self):
        return self.front.next.data

    # 置空队列
    def setEmpty(self):
        self.rear = self.front
        self.rear.next = None

    # 遍历队列
    def output(self):
        if self.empty(): return
        cnt = 0
        while not self.empty():
            cnt += 1
            if cnt > 1:
                print(' ', end='')
            print(self.getfront(), end='')
            self.pop()
        print()


a = Linqueue()
# for i in list(map(int, input('你就写吧').split())):
for i in [1, 3, 543, 2, 54, 5343, 423, 43645]:
    a.push(i)
a.output()
